package org.hxzon.tapestry5.components;

import java.math.BigDecimal;

import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.hxzon.util.BigDecimalUtil;

public class TextFieldWithSlider extends TextFieldEx {

    @Parameter
    @Property
    private BigDecimal maxValue;

    @Parameter
    @Property
    private BigDecimal defaultValue;

    @Parameter
    @Property
    private BigDecimal totalValue;

    public String getPercentId() {
        return getClientId() + "_percent";
    }

    public String getMaxId() {
        return getClientId() + "_max";
    }

    public String getDefaultId() {
        return getClientId() + "_default";
    }

    public String getDefaultPercentId() {
        return getClientId() + "_defaultPercent";
    }

    public String getTotalId() {
        return getClientId() + "_total";
    }

    public String getSliderId() {
        return "slider_" + getClientId();
    }

    public BigDecimal getDefaultPercent() {
        return BigDecimalUtil.divide(defaultValue, totalValue, 100);
    }

    public void setDefaultPercent(BigDecimal defaultPercent) {

    }

}
